package com.chen.state;

public class TestDaemon {
    public static void main(String[] args) {

        God god = new God();
        You you = new You();

        Thread thread = new Thread(god);
        // 设置为守护线程。默认false表示是用户线程，平时用的线程都是用户线程
        thread.setDaemon(true);
        thread.start();

        // 用户线程
        new Thread(you).start();

    }
}

class God implements Runnable {

    @Override
    public void run() {
        while (true) {
            System.out.println("上帝守护着你");
        }
    }
}

class You implements Runnable {

    @Override
    public void run() {
        for (int i = 0; i < 36500; i++) {
            System.out.println("每天开开心心活着");
        }
        System.out.println("===Goodbye, World！===");
    }
}
